<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>资源编辑</title>
	<%@ include file="../../include/head.jsp"%>
</head>
<body>
<div class="admin-content">
	<div class="am-g">
		<div class="am-u-sm-12">
			<form class="am-form am-form-horizontal" data-am-validator modelAttribute="resource" action="${ctx}/resource/update" method="post">
				<input type="hidden" name="id" value="${resource.id}" />
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label">上级节点：</label>
					<div class="am-u-sm-8">
						<input type="text" id="parentName" minlength="1" value="<c:choose><c:when test="${empty resource.resource.name}">根节点</c:when><c:otherwise>${resource.resource.name}</c:otherwise></c:choose>" readonly/>
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label"><span class="error">*</span>资源名称：</label>
					<div class="am-u-sm-8">
						<input type="text" name="name" minlength="1" value="${resource.name}" placeholder="资源名称（必填）" required />
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label">类型：</label>
					<div class="am-u-sm-8">
						<select name="type" data="${resource.type}">
							<c:forEach items="${types}" var="m">
								<option value="${m}">${m.info}</option>
							</c:forEach>
						</select>
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group isShow">
					<label class="am-u-sm-3 am-form-label"><span class="error">*</span>排序：</label>
					<div class="am-u-sm-8">
						<input type="number" name="sort" minlength="1" value="${resource.sort}" placeholder="排序（必填）" required />
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group isShow">
					<label class="am-u-sm-3 am-form-label">是否有下级：</label>
					<div class="am-u-sm-8">
						<select name="isSub" data="${resource.isSub}">
							<option value="true">是</option>
							<option value="false">否</option>
						</select>
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group isShow">
					<label class="am-u-sm-3 am-form-label">图标：</label>
					<div class="am-u-sm-8">
						<input type="text" id="icon" name="icon" class="am-form-field" placeholder="请填写class"
							   value="${resource.icon}" />
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label">URL路径：</label>
					<div class="am-u-sm-8">
						<input type="text" name="url" value="${resource.url}" />
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label">权限字符串：</label>
					<div class="am-u-sm-8">
						<input type="text" name="permission" value="${resource.permission}" />
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group">
					<label class="am-u-sm-3 am-form-label">是否可用：</label>
					<div class="am-u-sm-8">
						<select name="available" data="${resource.available}">
							<option value="true">可用</option>
							<option value="false">禁用</option>
						</select>
					</div>
					<label class="am-u-sm-1"></label>
				</div>
				<div class="am-form-group">
					<div class="am-u-sm-8 am-u-sm-push-3">
						<shiro:hasPermission name="sys:organization:edit"><button type="submit" class="am-btn am-btn-primary">保存</button></shiro:hasPermission>
						<button type="button" class="am-btn am-btn-danger" onclick="closeModel(false)">关闭</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<%@ include file="../../include/bottom.jsp"%>
<script type="text/javascript">
	$(function () {
		//消息提醒
		var msg = '${msg}';
		if(msg!=''){
			iuMsg(msg);
			closeModel(true);//关闭窗口
		}
		initSelectValue(true);//初始化下拉框的值

		//绑定事件
		$("select[name='type']").change(function(){
			if($(this).val()=="form"){
				$(".isShow").hide();
			}else{
				$(".isShow").show();
			}
		});
	});
</script>
</body>
</html>